﻿<%@ Page Title="" Language="C#" MasterPageFile="~/module/Fontend.Master" AutoEventWireup="true"
    CodeBehind="AlbumPhotoDetails.aspx.cs" Inherits="mamnontuoitho7.module.AlbumPhotoDetails" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <script language="javascript" type="text/javascript">
        function ClientComment_Click() {

            var commentContent = trim(document.getElementById("<%= txtComment.ClientID %>").value);
            var leng = commentContent.length;
            if (leng < 10 || leng > 300) {
                alert("Cần gõ hơn 10 ký tự và không quá 300 ký tự");
                return false;
            }
        }
        function CommentUpdate(i) {
            var commentContent = trim(document.getElementById("txtNewComment" + i).value);
            var leng = commentContent.length;
            if (leng < 10 || leng > 300) {
                alert("Cần gõ hơn 10 ký tự và không quá 300 ký tự");
                return false;
            }
        }
        function trim(str) {
            return str.replace(/^\s+|\s+$/g, "");
        }
    </script>
    <% if (_ds.Tables[0].Rows.Count > 0)
       {%>
    <div class="purple">
        <a href="Home.aspx">Trang chủ</a> &raquo; <a href="AlbumPhoto.aspx">Album ảnh</a> &raquo; <%= _ds.Tables[0].Rows[0]["Title"]%></div>
    <div class="albumdescription">
        <p>
            <%= _ds.Tables[0].Rows[0]["Introduce"]%>
        </p>
    </div>
    <div class="albumphoto">
        <%
    for (int i = 0; i < _ds.Tables[1].Rows.Count; i++)
    {
        %>
        <div class="albumdetail">
            <a class="group1" href="../images/album/album-<%= _productID %>/photo/<%= _ds.Tables[1].Rows[i]["ImageName"]%>">
                <img src="../images/album/album-<%= _productID %>/photo/thumbnail/<%= _ds.Tables[1].Rows[i]["ImageName"]%>"
                    alt="mam non tuoi tho 7" class="img141x106" />
            </a>
        </div>
        <%} %>
    </div>
     <%}
       else { 
       %>
        <div class="commingsoon">
            Album đã bị xóa hoặc dữ liệu không đúng ....
        </div>
       <%
       } %>
    <div class="albummore">
        <h1 class="h1_purple">Album khác:</h1>
        <div class="albumphoto">
            <div class="f-link-all">
                <div class="move">
                    <a href="javascropt:;" class="left prevsalea"></a><a href="javascropt:;" class="right nextsalea">
                    </a>
                </div>
            </div>
            <div class="slidera">

           <%  int  c;// là số lượng record trong 1 div
               int b = _dtOtherAlbum.Rows.Count;
               for (int i = 0; i < b; i++)
               {
           %>
                <div>
                    <%
                        if (i + 3 > b)// xác định div cuối
                        {
                            c = b % 3;  // số lượng record trong div cuối(trường hợp này là 3 record 1 div)
                        }
                        else
                        {
                            c = 3;
                        }
                    int j;
                    for ( j = 0; j < c;j++,i++ )
                      {
                    %>
                    <div class="album">
                        <a href="AlbumPhotoDetails.aspx?ProductID=<%=_dtOtherAlbum.Rows[i]["ProductID"].ToString()%>">
                            <img src="../images/album/album-<%= _dtOtherAlbum.Rows[i]["ProductID"].ToString()%>/<%= _dtOtherAlbum.Rows[i]["AlbumPhoto"].ToString()%>"
                                alt="<%= (_dtOtherAlbum.Rows[i]["AlbumPhoto"].ToString() != "") ? _dtOtherAlbum.Rows[i]["AlbumPhoto"].ToString() : "mam non tuoi tho 7" %>" class="img200x150" />
                        </a>
                        <p>
                            <%= _general.ReplaceSpecialCharacters(_general.CutString(_dtOtherAlbum.Rows[i]["Title"].ToString(), 30))%></p>
                        <a href="AlbumPhotoDetails.aspx?ProductID=<%=_dtOtherAlbum.Rows[i]["ProductID"].ToString()%>"
                            class="albumlink">Bình luận album này</a>
                    </div>
                    <%
                       
                     }
                        if (j == 3)//chạy xong for trong div.
                            i = i - 1;//phải giảm i 1 don vị, vì i++ xảy ra 2 lần
                    %>
                </div>
                <%} %>
                <%-- <div>
                <div class="album">
                    <button type="submit"><img src="../images/album/album1.jpg" alt="" class="img200x150"/></button>
                    <p>album ảnh 2</p>
                    <button type="submit" class="buttonalbum">Bình luận album này</button>
                </div>   
                <div class="album">
                    <button type="submit"><img src="../images/album/album1.jpg" alt="" class="img200x150"/></button>
                    <p>album ảnh 2</p>
                    <button type="submit" class="buttonalbum">Bình luận album này</button>
                </div>
                <div class="album">
                    <button type="submit"><img src="../images/album/album1.jpg" alt="" class="img200x150"/></button>
                    <p>album ảnh 2</p>
                    <button type="submit" class="buttonalbum">Bình luận album này</button>
                </div>
            </div>--%><!--end page 2-->
            </div>
        </div>
    </div>

    <form id="form1" runat="server">
        <div class="articlemore" style="margin-top: -30px;">
        <h1 class="h1_purple">
            Bình luận album:</h1>
        <div class="articlecomment">
            <asp:TextBox TextMode="MultiLine" ID="txtComment" runat="server"></asp:TextBox>
            <% if (Session["username"] != "")
            { %>
            <asp:Button ID="btnPostComment" runat="server" CssClass="buttons" Text="Bình luận"
                OnClientClick="return ClientComment_Click()" OnClick="btnPostComment_Click" />
            <% }
            else
            {%>
            <a href="#loginform" onclick="showhide('loginform');" class="buttons">Đăng nhập</a>
            <%} %>
        </div>
    </div>
    </form>

    <% if (_ds.Tables[0].Rows.Count > 0)
       {
        int _commentAmount = _dtComment.Rows.Count;
    %>
    <input type="hidden" id="hihCommentAmount" value="<%= _commentAmount%>" />
    <%--biến cầu nối chay js tren fontend--%>
    <%
        for (int i = 0; i < _commentAmount; i++)
        {
    %>
    <div class="commentdetail">
        <img src="../images/avatar/teacher_parents/<%= (_dtComment.Rows[i]["Avatar"].ToString() != "") ? _dtComment.Rows[i]["Avatar"].ToString() : "icon-avatar.png" %>" alt="" />
        <span class="arrow"><span></span></span>
        <div id="showcontent<%= i%>" class="blockcontent">
            <div class="content">
                <%= _general.ReplaceSpecialCharacters(_dtComment.Rows[i]["ContentComment"].ToString())%>
            </div>
            <div class="info">
                bởi <a href="ProfileInfo.aspx?MemberID=<%=_dtComment.Rows[i]["MemberID"].ToString() %>"  class="groupprofile">
                    <%= _dtComment.Rows[i]["FullName"].ToString()%></a> lúc:
                <%= DateTime.Parse(_dtComment.Rows[i]["CreateDate"].ToString()).ToString("dd/MM/yyyy HH:mm:ss")%>
                <% bool tempbool = _comment.checkCommentOwner(Session["username"].ToString(), _dtComment.Rows[i]["CommentID"].ToString());
                   if (tempbool)
                   { %>
                     <a href="#editcontent" onclick="hide('showcontent<%= i%>'); showhide('editcontent<%= i%>');"class="buttonlink">Sửa</a>
                  <%} %>
                  <%if (Session["role"].ToString() == "1" || Session["role"].ToString() == "2" || Session["role"].ToString() == "5" || Session["role"].ToString() == "7")
                    { %>
                       <a href="AlbumPhotoDetails.aspx?ProductID=<%= _productID %>&b=<%= _dtComment.Rows[i]["CommentID"].ToString()%>&Comment=1&page=<%=_pageflag %>"  class="buttonlink" onclick="javascript: if (confirm('Bạn muốn xóa comment này?')) { window.location.href='#' } else { return false; };">
                            Xóa
                       </a>
                  <%} %>
            </div>
        </div>
        <div id="editcontent<%= i%>" class="blockcontent">
            <% if (tempbool)
               { %>
            <form method="post" action="AlbumPhotoDetails.aspx?ProductID=<%= _productID %>&Comment=1&page=<%=_pageflag %>" id="formUpdate">
            <div class="content">
                <textarea id="txtNewComment<%= i%>" name="txtNewComment" class="textarea"><%= _dtComment.Rows[i]["ContentComment"].ToString()%></textarea>
                <input type="hidden" id="hidCommentID" name="hidCommentID" value="<%= _dtComment.Rows[i]["CommentID"].ToString()%>" />
                <input type="hidden" id="hidStatus" name="hidStatus" value="1" />
            </div>
            <div class="info">
                bởi <a href="ProfileInfo.aspx?MemberID=<%=_dtComment.Rows[i]["MemberID"].ToString() %>"  class="groupprofile">
                    <%= _dtComment.Rows[i]["FullName"].ToString()%></a> lúc:
                <%= DateTime.Parse(_dtComment.Rows[i]["CreateDate"].ToString()).ToString("dd/MM/yyyy HH:mm:ss")%>
                <a href="#showcontent" onclick="hide('editcontent<%= i%>'); showhide('showcontent<%= i%>');"
                    class="buttonlink">Hủy</a>
                <button type="submit" class="buttoncomment" onclick="return CommentUpdate(<%= i%>)">
                    Cập nhật
                </button>
                <%--  <input type="button" value="Cập nhật" class="buttoncomment" />--%>
            </div>
            </form>
            <%} %>
        </div>
    </div>
    <% }%>
    <%--<div class="commentdetail">
        <img src="../images/avatar/teacher_parents/aa.jpg" alt="" />
        <span class="arrow"><span></span></span>
        <div id="showcontent" class="blockcontent">
            <div class="content">
                đây là nội dung bài bình luận
            </div>
            <div class="info">
                bởi <a href="#">Sky Lee</a> lúc: 21/08/2012 10:09:29 AM
                <a href="#editcontent" onclick="hide('showcontent'); showhide('editcontent');" class="buttonlink">Sửa</a></div>
        </div>
        <div id="editcontent" class="blockcontent">
            <div class="content">
                <textarea id="txtNewComment" name="txtNewComment" class="textarea">đây là nội dung bài bình luận</textarea>
            </div>
            <div class="info">
                bởi <a href="#">Sky Lee</a> lúc: 21/08/2012 10:09:29 AM
                <a href="#showcontent" onclick="hide('editcontent'); showhide('showcontent');" class="buttonlink">Hủy</a>
                <input type="button" value="Cập nhật" class="buttoncomment" /></div>
        </div>
    </div>--%>
    <div id="container">
        <div class="pagination">
            <%if (_currentbar > 1)
              { %>
            <a href="AlbumPhotoDetails.aspx?a=-1&ProductID=<%= _productID %>" class="pagepurple"><<</a>
            <%} %>
            <%  

        for (int j = _beginPage; j <= _endPage; j++)
        {
            if (j == _pageflag)
            {
            
            %>
            <a href="AlbumPhotoDetails.aspx?page=<%= j%>&ProductID=<%= _productID %>" class="pagepurple active">
                <%= j%></a>
            <% }
            else
            { %>
            <a href="AlbumPhotoDetails.aspx?page=<%= j%>&ProductID=<%= _productID %>" class="pagepurple">
                <%= j%></a>
            <%  }
        } %>
            <%if (_currentbar < _totalBars)
              { %>
            <a href="AlbumPhotoDetails.aspx?a=1&ProductID=<%= _productID %>" class="pagepurple">>></a>
            <%} %>
        </div>
    </div>
    <%} %>
    <%--<div id="container">
        <div class="pagination">
            <a href="#" class="pagepurple"><<</a>
            <a href="#" class="pagepurple">2</a>
            <a href="#" class="pagepurple">3</a>
            <span class="pagepurple active">4</span>
            <a href="#" class="pagepurple">5</a>
            <a href="#" class="pagepurple">6</a>
            <a href="#"class="pagepurple">>></a>
        </div>
    </div>--%>
</asp:Content>
